/** @jsxImportSource @emotion/react */
import * as React from "react";
import {
  Text, CCell, Cell, Table, TableBody, TableRow,  TableHead,
} from "customize-easy-ui-component";
import {DirectLink} from "../../../routing/Link";
import {TailMenRowIspCheck} from "../../contain/rarelyVary";
import {useFixRowPrefUnt} from "../../hook/useFixRowPrefUnt";
import {items工作内容} from "./editItem";
// import {TableFoot, TableHead, CCell, Cell, Table, TableBody, TableRow,} from "../../../comp/Table";


const tailRender=(orc: any, name: string)=><>
  <CCell>{orc?.[name]?.r??'／'}</CCell>
  <CCell>{orc?.[name]?.m??'／'}</CCell>
</>;
export const AttachInspectItemsVw= ({orc, rep} :{orc:any, rep:any}
) => {
  //const theme= useTheme();
  //【注意】配置地一致性，split:[10,20] 需要和编辑器的拆分统一。 【助手】 JSON.parse(orc?._tblFixed??'[]') 【工具】
  const [renders]=useFixRowPrefUnt({orc, rep, config:items工作内容, tailRender,split:[14] });
  return <>
    <div css={{"@media print": {paddingBottom: '3.3rem', pageBreakInside: 'avoid'}} }>
      <Text id='AttachInspect1' variant="h2" css={{textAlign: 'center', marginTop: '1rem',
      }}>压力容器年度检查报告附页</Text>
      <div css={{display: 'flex', justifyContent: 'space-between'}}>
        <Text>单位内编号：{orc.单位内部编号}</Text>
        <Text>报告编号：{rep.isp.no}</Text>
      </div>
    </div>
    <Table fixed={ ["4.5%","5%","%","20%","26%"] } css={{borderCollapse: 'collapse', "@media print": {marginTop: '-3.3rem'}}} tight  miniw={800}>
      <TableHead>
          <TableRow>
            <CCell><Text css={{fontSize:'0.75rem'}}>序号</Text></CCell><CCell colSpan={2}>检查项目</CCell><CCell>检查结果</CCell><CCell>备注</CCell>
          </TableRow>
      </TableHead>
      <TableBody>
        <DirectLink href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/AttachInspect1#AttachInspect1`}>
          {renders[0]}
        </DirectLink>
        <DirectLink href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/AttachInspect2#AttachInspect2`}>
          {renders[1]}
        </DirectLink>
        <DirectLink href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/NonMetallic#NonMetallic`}>
          { orc?.非金表?.length>0? orc?.非金表.map((o: any, i: number) => {
                return (
                    <TableRow key={i}>
                      <CCell>{i+31}</CCell>
                      {i===0 && <CCell rowSpan={orc?.非金表?.length}><Text css={{display: 'block',fontSize: orc?.非金表?.length>=2 ?'0.8rem':'0.6rem'}}>非金属压力容器专项要求</Text></CCell>}
                      <CCell>{o.n}</CCell>
                      <CCell css={{whiteSpace:'pre-wrap'}}>{o.r??'／'}</CCell>
                      <CCell css={{whiteSpace:'pre-wrap'}}>{o.m??'／'}</CCell>
                    </TableRow>
                );
              } )
               :
            <TableRow><CCell>/</CCell>
                <CCell><Text css={{display: 'block',fontSize: '0.6rem'}}>非金属压力容器专项要求</Text></CCell>
            <CCell colSpan={3}>/</CCell></TableRow>
          }
        </DirectLink>
      </TableBody>
    </Table>
    <TailMenRowIspCheck orc={orc} rep={rep} cap={'检验'} href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/ProjectList#ProjectList`}>
      <DirectLink href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/NonMetallic#NonMetallic`}>
        <TableRow>
          <Cell colSpan={2}><div css={{
            minHeight: '3rem',whiteSpace:'pre-wrap'
          }}>备注：<br/>{orc.附页备注}</div></Cell>
        </TableRow>
      </DirectLink>
    </TailMenRowIspCheck>
    <Text css={{fontSize:'0.75rem'}}>
      注：无问题或者合格的检查项目在检查结果栏打“√”；检验项目存在一般问题在检查结果栏打“○”；检验项目存在严重 问题，单项结论为“不符合要求”或“不合格”在检查结果栏打“×”，并且在备注中说明；实际没有的检查项目在
      检查结果栏填写“无此项”或划“/”，或者按照实际的检查项目编制；无法检查的项目在检查结果栏中划“一”，并且在备注栏中 说明原因。
    </Text>
  </>;
};

